#!/usr/lib/python
# -*- coding:utf-8 -*-
import time
from datetime import date
import calendar


def date_test():
    """
    日期练习
    :return:
    """
    today = date.today()
    print(today)
    print(today.month)
    print(today.day)
    print(today.year)


def calendar_test():
    """
    日历练习
    :return:
    """
    cal = calendar.month(2016, 1)
    print "以下输出2016年1月份的日历:"
    print cal
    cal = calendar.calendar(2017, w=2, l=1, c=6)
    print "以下输出2017年年历:"
    print cal


def time_test():
    """
    时间练习
    :return:
    """
    ticks = time.time()
    print"当前时间戳为:", ticks
    localtime = time.localtime(ticks)
    print"本地时间为 :", localtime
    # 格式化成2016-03-20 11:45:39形式
    print time.strftime("%Y-%m-%d %H:%M:%S", localtime)

    # 格式化成Sat Mar 28 22:24:24 2016形式
    print time.strftime("%a %b %d %H:%M:%S %Y", localtime)

    # 将格式字符串转换为时间戳
    a = "Sat Mar 28 22:24:24 2016"
    print time.mktime(time.strptime(a, "%a %b %d %H:%M:%S %Y"))


if __name__ == "__main__":
    # date_test()
    # time_test()
    calendar_test()
